package cn.zhangtiancinb.simple_demo.http.scheduled;

import javax.annotation.Resource;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import cn.zhangtiancinb.simple_demo.http.utils.MessageConsumeUtil;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;

/**
 * MQ消费者
 *
 * @author 张天赐
 */
@Slf4j
@Component
@RabbitListener(queues = "${mq.delayed.topic}")
public class Consumer {
    /**
     * 消费工具
     */
    @Resource
    MessageConsumeUtil consumeUtil;

    /**
     * 消息消费回调
     *
     * @param message 消息内容
     */
    @RabbitHandler(isDefault = true)
    public void run(@Payload String message) {
        consumeUtil.submit(message);
    }
}
